import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

/**
 * Note: sub-menu only appear when route children.length >= 1
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * hidden: true                   if set true, item will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu
 *                                if not set alwaysShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    roles: ['admin','editor']    control the page roles (you can set multiple roles)
    title: 'title'               the name show in sidebar and breadcrumb (recommend set)
    icon: 'svg-name'/'el-icon-x' the icon show in the sidebar
    noCache: true                if set true, the page will no be cached(default is false)
    affix: true                  if set true, the tag will affix in the tags-view
    breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
    activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
  }
 */

/**
 * constantRoutes
 * a base page that does not have permission requirements
 * all roles can be accessed
 */
export const constantRoutes = [{
  path: '/redirect',
  component: Layout,
  hidden: true,
  children: [{
    path: '/redirect/:path(.*)',
    component: () =>
      import ('@/views/redirect/index')
  }]
},
{
  path: '/',
  redirect: '/login'
},
{
  path: '/login',
  component: () =>
    import ('@/views/login/index'),
  hidden: true
},
{
  path: '/auth-redirect',
  component: () =>
    import ('@/views/login/auth-redirect'),
  hidden: true
},
{
  path: '/404',
  component: () =>
    import ('@/views/error-page/404'),
  hidden: true
},
{
  path: '/401',
  component: () =>
    import ('@/views/error-page/401'),
  hidden: true
},

// 后台路由
{
  path: '/dashboard',
  component: Layout,
  children: [{
    path: 'index',
    component: () =>
      import ('@/views/dashboard/index'),
    name: 'dashboard',
    meta: { title: '欢迎', icon: 'dashboard', affix: true }
  }]
},
{
  path: '/zcfgaddform',
  component: Layout,
  hidden: true,
  children: [{
    path: 'index',
    component: () =>
      import ('@/webpage/zcfgaddform/index'),
    name: 'zcfgaddform',
    meta: { title: '政策法规', icon: 'dashboard' }
  }]
},
{
  path: '/gddtaddform',
  component: Layout,
  hidden: true,
  children: [{
    path: 'index',
    component: () =>
      import ('@/webpage/gddtaddform/index'),
    name: 'gddtaddform',
    meta: { title: '各地动态', icon: 'dashboard' }
  }]
},
{
  path: '/addform',
  component: Layout,
  hidden: true,
  children: [
    {
      path: 'index',
      component: () =>
      import ('@/webpage/addform/index'),
      name: 'addform',
      meta: { title: '内容管理', icon: 'dashboard' }
    },
    {
      path: 'zbrjlist',
      component: () =>
      import ('@/webpage/addform/zbrjIndex'),
      name: 'zbrjAddform',
      meta: { title: '值班日记内容管理', icon: 'dashboard' }
    },
    {
      path: 'zbrjEdit',
      component: () =>
      import ('@/webpage/addform/zbrjEditIndex'),
      name: 'zbrjEditform',
      meta: { title: '值班日记内容管理', icon: 'dashboard' }
    },
  ]
},
{
  path: '/jcsjaddform',
  component: Layout,
  hidden: true,
  children: [{
    path: 'index',
    component: () =>
      import ('@/webpage/jcsjaddform/index'),
    name: 'jcsjaddform',
    meta: { title: '内容管理', icon: 'dashboard' }
  }]
}, {
  path: '/tuwenaddform',
  component: Layout,
  hidden: true,
  children: [{
    path: 'index',
    component: () =>
      import ('@/webpage/tuwenaddform/index'),
    name: 'tuwenaddform',
    meta: { title: '内容管理', icon: 'dashboard' }
  }]
}
  // {
  //     path: '/dashboard',
  //     component: Layout,
  //     children: [{
  //         path: 'index',
  //         component: () =>
  //             import ('@/views/dashboard/index'),
  //         name: 'dashboard',
  //         meta: { title: '欢迎', icon: 'dashboard',affix:true }
  //     }]
  // },
]

export const asyncRoutes = [
  // 404 page must be placed at the end !!!

  { path: '*', redirect: '/404', hidden: true }
]

// 普通用户路由
// 我得文章
export const CustomerRoutes = [
  {
    path: '/approvalTransfer',
    component: Layout,
    children: [{
      path: 'index',
      component: () =>
        import ('@/webpage/approvalTransfer/index'),
      name: 'approvalTransfer',
      meta: { title: '转移审核管理', icon: 'dashboard' }
    }]
  },
  {
    path: '/submission',
    component: Layout,
    children: [{
      path: 'index',
      component: () =>
        import ('@/webpage/addform/index'),
      name: 'submission',
      meta: { title: '快速投稿', icon: 'dashboard' }
    }]
  },
  {
    path: '/myarticlelist',
    component: Layout,
    children: [{
      path: '',
      component: () =>
        import ('@/webpage/myarticlelist/index'),
      name: 'myarticlelist',
      meta: { title: '我的文章', icon: 'dashboard' }
    }]
  },
  // 下载中心
  {
    path: '/xzzxaddform',
    component: Layout,
    hidden: true,
    children: [{
      path: 'index',
      component: () =>
        import ('@/webpage/xzzxaddform/index'),
      name: 'xzzxaddform',
      meta: { title: '下载中心', icon: 'dashboard' }
    }]
  }
]
// admin
export const principalRoutes = [
  {
    path: '/articlelist',
    component: Layout,
    children: [{
      path: 'index',
      component: () =>
        import ('@/webpage/articlelist/index'),
      name: 'articlelist',
      meta: { title: '审核管理', icon: 'dashboard' }
    }]
  },
  {
    path: '/webmember',
    component: Layout,
    children: [{
      path: 'index',
      component: () =>
        import ('@/webpage/webmember/index'),
      name: 'webmember',
      meta: { title: '用户管理', icon: 'dashboard' }
    }]
  },
  {
    path: '/submission',
    component: Layout,
    children: [{
      path: 'index',
      component: () =>
        import ('@/webpage/addform/index'),
      name: 'submission',
      meta: { title: '快速投稿', icon: 'dashboard' }
    }]
  },
  {
    path: '/myarticlelist',
    component: Layout,
    children: [{
      path: '',
      component: () =>
        import ('@/webpage/myarticlelist/index'),
      name: 'myarticlelist',
      meta: { title: '我的文章', icon: 'dashboard' }
    }]
  },
  {
    path: '/organizeation',
    component: Layout,
    children: [{
      path: 'index',
      component: () =>
        import ('@/webpage/organizeation/index'),
      name: 'organizeation',
      meta: { title: '机构管理', icon: 'dashboard' }
    }]
  },
  {
    path: '/iplist',
    component: Layout,
    children: [{
      path: 'index',
      component: () =>
        import ('@/webpage/iplist/index'),
      name: 'iplist',
      meta: { title: '访问权限设置', icon: 'dashboard' }
    }]
  },
  {
    path: '/Ipstatistics',
    component: Layout,
    children: [{
      path: 'index',
      component: () =>
        import ('@/webpage/Ipstatistics/index'),
      name: 'Ipstatistics',
      meta: { title: '首页访问统计', icon: 'dashboard' }
    }]
  },
  // {
  //     path: '/date',
  //     component: Layout,
  //     children: [{
  //         path: 'index',
  //         component: () =>
  //             import ('@/webpage/date/index'),
  //         name: 'date',
  //         meta: { title: '今日排班', icon: 'dashboard'}
  //     }]
  // },
  // {
  //     path: '/moban',
  //     component: Layout,
  //     children: [{
  //         path: 'index',
  //         component: () =>
  //             import ('@/webpage/moban/index'),
  //         name: 'moban',
  //         meta: { title: '排班模板', icon: 'dashboard'}
  //     }]
  // },
  {
    path: '/control',
    component: Layout,
    children: [{
      path: 'index',
      component: () =>
        import ('@/webpage/control/index'),
      name: 'control',
      meta: { title: '控制弹出方式', icon: 'dashboard' }
    }]
  },
  // 注释广告管理功能
  {
    path: '/advertising',
    component: Layout,
    children: [{
      path: 'index',
      component: () =>
        import ('@/webpage/advertising/index'),
      name: 'control',
      meta: { title: '广告管理', icon: 'dashboard' }
    }]
  },
  {
    path: '/bannerManager',
    component: Layout,
    children: [{
      path: 'index',
      component: () =>
        import ('@/webpage/bannerManager/index'),
      name: 'bannerManager',
      meta: { title: 'Banner管理', icon: 'dashboard' }
    }]
  },
  {
    path: '/Columnmanagement',
    component: Layout,
    children: [{
      path: 'index',
      component: () =>
        import ('@/webpage/Columnmanagement/index'),
      name: 'Columnmanagement',
      meta: { title: '栏目管理', icon: 'dashboard' }
    }]
  },
  {
      path: '/userlist',
      component: Layout,
      children: [{
          path: 'index',
          component: () =>
              import ('@/webpage/userlist/index'),
          name: 'userlist',
          meta: { title: '值班人员', icon: 'dashboard' }
      }]
  },
  // {
  //     path: '/szywlist',
  //     component: Layout,
  //     children: [{
  //         path: 'index',
  //         component: () =>
  //             import ('@/webpage/szywlist/index'),
  //         name: 'szywlist',
  //         meta: { title: '时政要闻', icon: 'dashboard'}
  //     }]
  // },
  // {
  //     path: '/ldpslist',
  //     component: Layout,
  //     children: [{
  //         path: 'index',
  //         component: () =>
  //             import ('@/webpage/ldpslist/index'),
  //         name: 'ldpslist',
  //         meta: { title: '领导批示', icon: 'dashboard'}
  //     }]
  // },
  // {
  //     path: '/ldjhlist',
  //     component: Layout,
  //     children: [{
  //         path: 'index',
  //         component: () =>
  //             import ('@/webpage/ldjhlist/index'),
  //         name: 'ldjhlist',
  //         meta: { title: '领导讲话', icon: 'dashboard'}
  //     }]
  // },{
  //     path: '/bgrklist',
  //     component: Layout,
  //     children: [{
  //         path: 'index',
  //         component: () =>
  //             import ('@/webpage/bgrklist/index'),
  //         name: 'bgrklist',
  //         meta: { title: '办公入口', icon: 'dashboard'}
  //     }]
  // },
  // {
  //     path: '/tzgglist',
  //     component: Layout,
  //     children: [{
  //         path: 'index',
  //         component: () =>
  //             import ('@/webpage/tzgglist/index'),
  //         name: 'tzgglist',
  //         meta: { title: '通知公告', icon: 'dashboard'}
  //     }]
  // }, {
  //     path: '/gzjblist',
  //     component: Layout,
  //     children: [{
  //         path: 'index',
  //         component: () =>
  //             import ('@/webpage/gzjblist/index'),
  //         name: 'gzjblist',
  //         meta: { title: '工作简报', icon: 'dashboard'}
  //     }]
  // },
  // {
  //     path: '/jgdtlist',
  //     component: Layout,
  //     children: [{
  //         path: 'index',
  //         component: () =>
  //             import ('@/webpage/jgdtlist/index'),
  //         name: 'jgdtlist',
  //         meta: { title: '机关动态', icon: 'dashboard'}
  //     }]
  // },{
  //     path: '/jjblist',
  //     component: Layout,
  //     children: [{
  //         path: 'index',
  //         component: () =>
  //             import ('@/webpage/jjblist/index'),
  //         name: 'jjblist',
  //         meta: { title: '交接班', icon: 'dashboard'}
  //     }]
  // },{
  //     path: '/gddtlist',
  //     component: Layout,
  //     children: [{
  //         path: 'index',
  //         component: () =>
  //             import ('@/webpage/gddtlist/index'),
  //         name: 'gddtlist',
  //         meta: { title: '各地动态', icon: 'dashboard'}
  //     }]
  // },
  // {
  //     path: '/tcyjlist',
  //     component: Layout,
  //     children: [{
  //         path: 'index',
  //         component: () =>
  //             import ('@/webpage/tcyjlist/index'),
  //         name: 'tcyjlist',
  //         meta: { title: '调查研究', icon: 'dashboard'}
  //     }]
  // },{
  //     path: '/llqylist',
  //     component: Layout,
  //     children: [{
  //         path: 'index',
  //         component: () =>
  //             import ('@/webpage/llqylist/index'),
  //         name: 'llqylist',
  //         meta: { title: '理论前沿', icon: 'dashboard'}
  //     }]
  // },{
  //     path: '/zdswlist',
  //     component: Layout,
  //     children: [{
  //         path: 'index',
  //         component: () =>
  //             import ('@/webpage/zdswlist/index'),
  //         name: 'zdswlist',
  //         meta: { title: '总队收文', icon: 'dashboard'}
  //     }]
  // },{
  //     path: '/gzdblist',
  //     component: Layout,
  //     children: [{
  //         path: 'index',
  //         component: () =>
  //             import ('@/webpage/gzdblist/index'),
  //         name: 'gzdblist',
  //         meta: { title: '跟踪督办', icon: 'dashboard'}
  //     }]
  // }, {
  //     path: '/ljzclist',
  //     component: Layout,
  //     children: [{
  //         path: 'index',
  //         component: () =>
  //             import ('@/webpage/ljzclist/index'),
  //         name: 'ljzclist',
  //         meta: { title: '廉政之窗', icon: 'dashboard'}
  //     }]
  // },
  // {
  //     path: '/dyyclist',
  //     component: Layout,
  //     children: [{
  //         path: 'index',
  //         component: () =>
  //             import ('@/webpage/dyyclist/index'),
  //         name: 'dyyclist',
  //         meta: { title: '队员原创', icon: 'dashboard'}
  //     }]
  // },{
  //     path: '/tszslist',
  //     component: Layout,
  //     children: [{
  //         path: 'index',
  //         component: () =>
  //             import ('@/webpage/tszslist/index'),
  //         name: 'tszslist',
  //         meta: { title: '他山之石', icon: 'dashboard'}
  //     }]
  // },{
  //     path: '/mtjjlist',
  //     component: Layout,
  //     children: [{
  //         path: 'index',
  //         component: () =>
  //             import ('@/webpage/mtjjlist/index'),
  //         name: 'mtjjlist',
  //         meta: { title: '媒体聚焦', icon: 'dashboard'}
  //     }]
  // },{
  //     path: '/jcsjlist',
  //     component: Layout,
  //     children: [{
  //         path: 'index',
  //         component: () =>
  //             import ('@/webpage/jcsjlist/index'),
  //         name: 'jcsjlist',
  //         meta: { title: '精彩瞬间', icon: 'dashboard'}
  //     }]
  // },
  // {
  //     path: '/jcsplist',
  //     component: Layout,
  //     children: [{
  //         path: 'index',
  //         component: () =>
  //             import ('@/webpage/jcsplist/index'),
  //         name: 'jcsplist',
  //         meta: { title: '精彩视频', icon: 'dashboard'}
  //     }]
  // },

  // {
  //     path: '/spdblist',
  //     component: Layout,
  //     children: [{
  //         path: 'index',
  //         component: () =>
  //             import ('@/webpage/spdblist/index'),
  //         name: 'spdblist',
  //         meta: { title: '视频点播', icon: 'dashboard'}
  //     }]
  // },{
  //     path: '/lbxwlist',
  //     component: Layout,
  //     children: [{
  //         path: 'index',
  //         component: () =>
  //             import ('@/webpage/lbxwlist/index'),
  //         name: 'lbxwlist',
  //         meta: { title: '轮播新闻', icon: 'dashboard'}
  //     }]
  // },    {
  //     path: '/xzzxlist',
  //     component: Layout,
  //     children: [{
  //         path: 'index',
  //         component: () =>
  //             import ('@/webpage/xzzxlist/index'),
  //         name: 'xzzxlist',
  //         meta: { title: '下载中心', icon: 'dashboard'}
  //     }]
  // },
  {
    path: '/xzzxaddform',
    component: Layout,
    hidden: true,
    children: [{
      path: 'index',
      component: () =>
        import ('@/webpage/xzzxaddform/index'),
      name: 'xzzxaddform',
      meta: { title: '下载中心', icon: 'dashboard' }
    }]
  }
//  {
//     path: '/zcfglist',
//     component: Layout,
//     children: [{
//         path: 'index',
//         component: () =>
//             import ('@/webpage/zcfglist/index'),
//         name: 'zcfglist',
//         meta: { title: '政策法规', icon: 'dashboard'}
//     }]
// }, {
//     path: '/zdgkdetails',
//     component: Layout,
//     children: [{
//         path: 'index',
//         component: () =>
//             import ('@/webpage/zdgkdetails/index'),
//         name: 'zdgkdetails',
//         meta: { title: '支队概况', icon: 'dashboard'}
//     }]
// },{
//     path: '/txldetails',
//     component: Layout,
//     children: [{
//         path: 'index',
//         component: () =>
//             import ('@/webpage/txldetails/index'),
//         name: 'txldetails',
//         meta: { title: '通讯录', icon: 'dashboard'}
//     }]
// },{
//     path: '/tuwenlist',
//     component: Layout,
//     children: [{
//         path: 'index',
//         component: () =>
//             import ('@/webpage/tuwenlist/index'),
//         name: 'tuwenlist',
//         meta: { title: '图文链接管理', icon: 'dashboard'}
//     }]
// },{
//     path: '/yqljlist',
//     component: Layout,
//     children: [{
//         path: 'index',
//         component: () =>
//             import ('@/webpage/yqljlist/index'),
//         name: 'yqljlist',
//         meta: { title: '友情链接', icon: 'dashboard'}
//     }]
// },
]

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
